package com.immunology.database.transformers;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.log4j.Logger;

import com.immunology.core.BaseTransformer;
import com.immunology.database.DbColumns;
import com.immunology.model.SurveyAnswer;

public class SurveyAnswerTransformer extends BaseTransformer<SurveyAnswer> {
	private static final Logger LOG = Logger
			.getLogger(ComplaintTransformer.class);

	@Override
	public SurveyAnswer transformTo(ResultSet resultSet) {
		SurveyAnswer surveyAnswer = new SurveyAnswer();
		try {
			surveyAnswer.setId(resultSet.getInt(DbColumns.FIRST_COLUMN));
			surveyAnswer.setComplaintId(resultSet
					.getInt(DbColumns.SECOND_COLUMN));
			surveyAnswer.setSurveyId(resultSet
					.getInt(DbColumns.THIRD_COLUMN));
			surveyAnswer.setValue(resultSet
					.getInt(DbColumns.FOURTH_COLUMN));
			surveyAnswer.setDescription(resultSet
					.getString(DbColumns.FIFTH_COLUMN));
		} catch (SQLException e) {
			LOG.error("Can't create SurveyAnswerTransformer object:", e);
		}
		return surveyAnswer;
	}

}